package com.sz.biz.app.web.security;

import com.sz.common.base.dto.ResultDto;
import org.apache.shiro.web.filter.authc.FormAuthenticationFilter;

import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import java.io.IOException;

/**
 * Function: MyFormAuthenticationFilter <br>
 * Author: Charles <br>
 * Date: 2017-01-05 10:22:00
 */
public class MyFormAuthenticationFilter extends FormAuthenticationFilter {

    @Override
    protected void redirectToLogin(ServletRequest request, ServletResponse response) throws IOException {
        //String loginUrl = this.getLoginUrl();
        //WebUtils.issueRedirect(request, response, loginUrl);
        ResultDto dto = new ResultDto(401, "please login first");
        response.getWriter().write(dto.toString());
        response.flushBuffer();
    }
}
